import { defineStore } from "pinia";
import { theme as antdTheme } from "ant-design-vue";
import { useLocalRef } from "@/framework/vue/hooks/state.ts";

/**
 * 主题名称
 */
export type ThemeVariant = "light" | "dark";

/**
 * 自定义主题
 */
export const useCustomTheme = defineStore("theme", () => {
  /**
   * 主题定义
   */
  const themeVariants: Record<ThemeVariant, any> = {
    light: antdTheme.defaultAlgorithm,
    dark: antdTheme.darkAlgorithm,
  };

  /**
   * 当前使用主题名称
   */
  const variant = useLocalRef<ThemeVariant>("theme.variant", "dark");

  /**
   * 主题色
   */
  const colorPrimary = useLocalRef<string>("theme.color.primary", "#A277FF");

  return {
    themeVariants: themeVariants,
    variant: variant,
    colorPrimary: colorPrimary,
  };
});
